<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>检定校准执行</title>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script type="text/javascript" src="../../js/jquery/jquery-1.9.1.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019072018:09" type="text/javascript" charset="utf-8"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script src="/lib/layui/layui/js/common.js?v=20190723" type="text/javascript" charset="utf-8"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .layui-form .one{
            width: 100%;
            display: flex;
            flex-flow: row wrap;
            justify-content: space-around;
        }
        .layui-form-item {
            margin-right: 2%;
            width: 48%;
        }
        select{
            width: 100%;
            height: 38px;
        }
        input::-webkit-input-placeholder {
            color: #aab2bd;
        }
        .buttonbottom button{
            background-color: #009284;
            width: 90px;
            margin-top: 30px;
        }
        .layui-treeSelect .ztree li span.button.root_open:before, .layui-treeSelect .ztree li span.button.root_close:before{
            content: "\e623";
        }
        .layui-form-selectup dl {
            top: 42px;
            bottom: unset;
        }
        /*#experiencebase .layui-table{*/
        /*width: 100%!important;*/
        /*}*/
        form{
            width: 100%;
            margin: 0 auto;
        }
        .Basics{
            width:100%;
            height: 50px;
            line-height: 50px;
            margin-left:5px;
        }
        .Basics li{
            float:left;
            margin-right:80px;
        }
        .Basics li span{
            margin-left:10px;
        }
        .title {
            width:100%;
            height: 36px;
            line-height: 36px;
            background-color: #eeeeee;
            margin: 15px auto;
        }
        .title span{
            font-weight:bold;
            margin-left: 6px;
        }
        .widths{
            width:100%;
        }
        .concluIntegrity>label,.concluRange>label,.concluResult>label{
            width: 186px
        }
        .layui-form-label {
            width: 108px;
            padding: 9px 0px;
        }
        .Required {
            color: red;
        }
        .Situation_Explain{
            height: 38px;
        }
        .Situation_Explain span{
            margin-left:38px;
        }
        .not_click{
            cursor: not-allowed;
            background: #f1f1f5;
        }
    </style>
</head>
<body>
<div class="mbox">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" lay-filter="formTest" action="">
                <input type="hidden" class="equipId" name="equipId" value="">

                <%--基本信息--%>
                <div class="title"><span>基本信息</span></div>
                <ul class="Basics">
                    <li>设备名称：<span class="equipName"></span></li>
                    <li>固定资产编号：<span class="equipNo"></span></li>
                    <li>出厂编号：<span class="factoryNo"></span></li>
                    <li>型号：<span class="modelNo"></span></li>
                    <li>所属部门：<span class="deptId"></span></li>
                </ul>
                <div class="one">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="Required">*</span>检定/校准日期：</label>
                        <div class="layui-input-block" id="deptoper">
                            <input type="text" name="dateTime" placeholder="请选择检定/校准日期" autocomplete="off" class="layui-input exeTime">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">检定/校准周期：</label>
                        <div class="layui-input-block">
                            <%--<input type="text" name="frequency" placeholder="请输入检定/校准周期" autocomplete="off" class="layui-input frequency">--%>
                            <select name="frequency" lay-verify="required" class="frequency" disabled="disabled">
                                <option value=""></option>
                                <option value="1">每两年</option>
                                <option value="2">每年</option>
                                <option value="3">每月</option>
                                <option value="4">每季度</option>
                                <option value="5">每周</option>
                                <option value="6">每天</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="one">
                    <div class="layui-form-item">
                        <label class="layui-form-label">证书编号：</label>
                        <div class="layui-input-block">
                            <input type="text" name="certNo" placeholder="请输入证书编号(数字类型)" autocomplete="off" class="layui-input certNo" oninput="value=value.replace(/[^\d]/g,'')">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">检定/校准单位：</label>
                        <div class="layui-input-block" >
                            <input type="text" name="company"  placeholder="请输入检定/校准单位" disabled="disabled" autocomplete="off" class="layui-input company not_click">
                        </div>
                    </div>
                </div>

                <%--技术指标--%>
                <div class="title"><span>技术指标</span></div>
                <div class="addtabs">
                    <button type="button" data-type="0" id="addTableButton" class="layui-btn layui-btn-sm" lay-event="add_implement">添加</button>
                </div>
                <div id="technicalDiv">
                    <table class="" id="technical" lay-filter="technical"></table>
                </div>
                <%--确认结论--%>
                <div class="title"><span>确认结论</span></div>
                <div class="layui-form-item widths concluResult">
                    <label class="layui-form-label">确认结论：</label>
                    <div class="layui-input-block">
                        <input type="radio" name="confirm_conclusion" value="0" title="设备参数正常，运行良好" checked>
                        <input type="radio" name="confirm_conclusion" value="1" title="设备参数异常，存在故障">
<%--
                        <input type="radio" name="confirm_conclusion" value="2" title="误差+不确定度结果超差时增加期间核查">
--%>
                    </div>
                </div>
                <div class="one">
                    <div class="layui-form-item" style="width: 35%;">
                        <label class="layui-form-label">确认人员：</label>
                        <div class="layui-input-block">
                            <input type="text" name="concluUser" placeholder="请输入确认人员" autocomplete="off" class="layui-input concluUser">
                        </div>
                    </div>
                    <div class="layui-form-item" style="width: 35%;">
                        <label class="layui-form-label">确认时间：</label>
                        <div class="layui-input-block">
                            <input type="text" name="dateTime" placeholder="请选择确认时间" autocomplete="off" class="layui-input concluAddtime">
                        </div>
                    </div>
                </div>

                <%--审核意见--%>
                <div class="title"><span>审核意见</span></div>
                <div style="display: flex">
                    <div class="layui-form-item widths auditmind">
                        <label class="layui-form-label">审核意见：</label>
                        <div class="layui-input-block" style="display:flex">
                            <input type="radio" name="Audit_opinion" value="0" title="设备参数正常，运行良好" checked>
                            <input type="radio" name="Audit_opinion" value="1" title="设备参数异常，存在故障">
                        </div>
                    </div>
                </div>
                <div class="one" style="justify-content: flex-start;">
                    <div class="layui-form-item" style="width: 37%;">
                        <label class="layui-form-label">审核人员：</label>
                        <div class="layui-input-block">
                            <input type="text" name="approver" placeholder="请输入审核人员" autocomplete="off" class="layui-input approver">
                        </div>
                    </div>
                    <div class="layui-form-item" style="width: 37%;">
                        <label class="layui-form-label">审核时间：</label>
                        <div class="layui-input-block">
                            <input type="text" name="dateTime" placeholder="请选择审核时间" autocomplete="off" class="layui-input approverTime">
                        </div>
                    </div>
                </div>

                <%--标识发放情况--%>
                <div class="title"><span>标识发放情况</span></div>
                <div class="layui-form-item widths identType">
                    <label class="layui-form-label">标识分类：</label>
                    <div class="layui-input-block">
                        <input type="radio" name="Identification_classification" value="0" title="合格证" checked>
                        <input type="radio" name="Identification_classification" value="1" title="准用证">
                        <input type="radio" name="Identification_classification" value="2" title="限用证">
                        <input type="radio" name="Identification_classification" value="3" title="停用证">
                    </div>
                </div>
                <div class="one">
                    <div class="layui-form-item">
                        <label class="layui-form-label">发放人员：</label>
                        <div class="layui-input-block">
                            <input type="text" name="grantUser" placeholder="请输入发放人员" autocomplete="off" class="layui-input grantUser">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">发放时间：</label>
                        <div class="layui-input-block">
                            <input type="text" placeholder="请选择发放时间" autocomplete="off" class="layui-input grantTime">
                        </div>
                    </div>
                </div>
                <div  class="Situation_Explain">
                    <span>其他情况说明： 状态标识领取人员在状态标识领取后，须在24小时内将标识粘贴在测量仪器设备规定的位置上。</span>
                </div>
                <div class="one">
                    <div class="layui-form-item">
                        <label class="layui-form-label">领取人员：</label>
                        <div class="layui-input-block">
                            <input type="text" name="receiveUser" placeholder="请输入领取人员" autocomplete="off" class="layui-input receiveUser">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">领取时间：</label>
                        <div class="layui-input-block">
                            <input type="text" placeholder="请选择领取时间" autocomplete="off" class="layui-input receiveTime">
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<%--开关按钮模板--%>
<script type="text/html" id="addTableDel">
    <input type="checkbox" name="conclusion" value="{{d.conclusion}}" lay-skin="switch" lay-text="符合|不符合" lay-filter="switchTest" {{ d.conclusion==1?'checked':''}}>
</script>
<script>;

var eventId='';//选中行的id
var equipEventType='';//头部tab切换属性
var equipId='';//设备ID
var deptId='';//所属部门
var equipTypeId='';//设备类型ID
var equipStatus='';//设备状态
var tableData;
var data=[];
var conclusion='';//确认结论
// var eventStatus='';//事件状态
// var remindDays='';//提前天数
// 基本信息数据回显
function child(data){
    eventId=data.eventId;
    equipEventType=data.equipEventType;
    equipId=data.equipId;
    deptId=data.deptId;
    equipTypeId=data.equipTypeId;
    equipStatus=data.equipStatus;
    eventStatus=data.eventStatus;
    remindDays=data.remindDays;
    lastExeTime=data.lastExeTime;
    nestExeTime=data.nestExeTime;

    data.equipName!=undefined||''?$('.equipName').text(data.equipName):$('.equipName').text('无');//设备名称
    data.equipNo!=undefined||''?$('.equipNo').text(data.equipNo):$('.equipNo').text('无');//固定资产编号
    data.factoryNo!=undefined||''?$('.factoryNo').text(data.factoryNo):$('.factoryNo').text('无');//出厂编号
    data.modelNo!=undefined||''?$('.modelNo').text(data.modelNo):$('.modelNo').text('无');//型号
    data.deptName!=undefined||''?$('.deptId').text(data.deptName):$('.deptId').text('无');//所属部门
    $('.company').val(data.company);//检定/校准单位
    $('.frequency').val(data.frequency);//维护频率
    layui.form.render('select');
    $('.equipId').val(data.equipId);//设备 equipId
}

layui.use(['form', 'layer','table','laydate'], function() {
    var form = layui.form;
    var layer = layui.layer;
    var laydate = layui.laydate;
    var table = layui.table;
    tableData=table;
    var $ = layui.jquery;

    //添加日期
    $("input[name=dateTime]").each(function(){
        laydate.render({
            elem: this
            , trigger: 'click'
            , format: 'yyyy-MM-dd'
        });
    })

    //选择发放时间
    var startDate=laydate.render({
        elem: '.grantTime',
        trigger: 'click',
        format: 'yyyy-MM-dd',
        done: function(value, date){
            endDate.config.min ={
                year:date.year,
                month:date.month-1, //关键
                date: date.date
            };
        }
    });

    //选择领取时间
    var endDate= laydate.render({
        elem: '.receiveTime',//选择器结束时间
        trigger: 'click',
        format: 'yyyy-MM-dd',
        min:$('.grantTime').val(),//设置min默认最小值
        done: function(value,date){
            startDate.config.max={
                year:date.year,
                month:date.month-1,//关键
                date: date.date
            }
        }
    });

    // 技术指标表格
    table.render({
        elem: '#technical'
        ,data:[{}]
        // ,page: {
        //     layout: ['prev', 'page', 'next',  'skip','count','limit',]
        //     ,limits:[5,10,15,20,25,30,35,40,45,50]
        // }
        // ,limit:5
        ,cols: [[
            {field:'paraName', title:'指标项目',edit:true}
            ,{field:'uncertainty', title:'不确定度',edit:true}
            ,{field:'error', title:'误差',edit:true}
            ,{field:'initialValue', title:'规定值',edit:true}
            ,{field:'calibrationValue', title:'检测/校准值',edit:true}
            ,{field:'conclusion', title:'确认结论', align: 'center',toolbar: '#addTableDel'}
        ]]
    });

    //技术指标 table 添加功能
    $("#addTableButton").click(function () {
        data=table.cache["technical"];
        var obj={                  //特殊初始赋值
            paraName:'',//指标项目
            uncertainty:'',//不确定度
            error:'',//误差
            initialValue:'',//规定值
            calibrationValue:'',//检测/校准值
            conclusion:''//确认结论
        };
        data.push(obj);
        table.reload('technical',{
            data : data
        });
    });

    // 确认结论 switch开关监听
    form.on('switch(switchTest)', function(data){
        data.elem.checked==true?$(this).attr('value',1):$(this).attr('value',0);
        conclusion=table.cache["technical"];
        var dayObj=$('input[name="conclusion"]');
        for(var i=0;i<dayObj.length;i++){
            conclusion[i].conclusion=dayObj[i].getAttribute('value');
        }
    });
})

//获取 页面 数据
function getimplementDate(){
    var implementDate={
        eventId:eventId,//选中行的id
        equipStatus:equipStatus,//设备状态
        // eventStatus:eventStatus,//事件状态
        // remindDays:remindDays,//提前天数
        equipEventType:equipEventType,//头部tab切换属性
        equipId:equipId,//设备ID
        deptId:deptId,//所属部门
        equipTypeId:equipTypeId,//设备类型ID
        equipName:$('.equipName').text(),//设备名称
        equipNo:$('.equipNo').text(),//固定资产编号
        factoryNo:$('.factoryNo').text(),//出厂编号
        modelNo:$('.modelNo').text(),//型号
        exeTime:$('.exeTime').val(),//检定/校准日期
        frequency:$('.frequency').val(),//检定/校准周期
        // company:$('.company').val(),//检定/校准单位
        certNo:$('.certNo').val(),//证书编号
        concluIntegrity:$('input[name=Completeness]:checked').val(),//检定/校准项目完整性确认
        concluRange:$('input[name=measuring_range]:checked').val(),//检定/校准项目测量范围确认
        concluResult:$('input[name=confirm_conclusion]:checked').val(),//确认结论
        concluUser:$('.concluUser').val(),//确认人员
        concluAddtime:$('.concluAddtime').val(),//确认时间
        auditmind:$('input[name=Audit_opinion]:checked').val(),//审核意见
        approver:$('.approver').val(),//审核人员
        approverTime:$('.approverTime').val(),//审核时间
        identType:$('input[name=Identification_classification]:checked').val(),//标识分类
        grantUser:$('.grantUser').val(),//发放人员
        grantTime:$('.grantTime').val(),//发放时间
        receiveUser:$('.receiveUser').val(),//领取人员
        receiveTime:$('.receiveTime').val(),//领取时间
    }
    return implementDate;
}
</script>
</body>
</html>